package demo.day09

// 解构
fun main() {
    // 结构结果
    val (name, age, sex) = Student("Kiki", 18, 'm')
    println("普通类解构结果：name:$name,age:$age,sex:$sex")

    val (name1, age1, sex1) = Student1("Kiki", 18, 'm')
    println("普通类解构结果：name:$name1,age:$age1,sex:$sex1")
}

class Student(var name: String, var age: Int, var sex: Char) {
    // 注意事项 component 顺序必须是component1 component2 component3 和成员一一对应
    // 顺序下来
    operator fun component1() = name
    operator fun component2() = age
    operator fun component3() = sex
}

// 数据类内部会封装好 直接用就行
data class Student1(var name: String, var age: Int, var sex: Char)



